from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate,ChatMessagePromptTemplate
from pydantic import SecretStr
from langchain_core.tools import tool
from pydantic import BaseModel, Field

model = "qwen3-max"
# 初始化LLM模型
llm: ChatOpenAI= ChatOpenAI(
    model=model,
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
    api_key=SecretStr("sk-42f84356d53a44ecbdbaebbeb5a12738"),
    streaming=True,

)

# system_message_template
system_message_template: ChatMessagePromptTemplate = ChatMessagePromptTemplate.from_template(
    template="你是一个{role}专家，擅长回答{domain}领域的问题",
    role="system"
)
human_message_template: ChatMessagePromptTemplate = ChatMessagePromptTemplate.from_template(
    template="用户的问题{question}",
    role="user"
)

# chatPrompt
chat_prompt_template: ChatPromptTemplate = ChatPromptTemplate.from_messages([
    system_message_template,
    human_message_template
    ])


class AddInputArgs(BaseModel):
    a: int = Field(description="fitst number")
    b: int = Field(description="second number")

@tool(
    description="add two numbers",
    args_schema=AddInputArgs
    return_direct=False
)

def add(a,b):
    """add two numbers"""
    return a + b

def create_calc_tools():
    return [add]

calc_tools = create_calc_tools()
